import { HALF_PI, getBaseLength, getThirdPoint } from "./PlotUtil";

export default class StraightArrow {
	static tailWidthFactor = 0.15;
	static tailWidthFactor = 0.15;
	static neckWidthFactor = 0.2;
	static headWidthFactor = 0.25;
	static headAngle = Math.PI / 8.5;
	static neckAngle = Math.PI / 13;

	static generate(pnts) {
		const pnt1 = pnts[0];
		const pnt2 = pnts[1];
		const len = getBaseLength(pnts);
		const tailWidth = len * this.tailWidthFactor;
		const neckWidth = len * this.neckWidthFactor;
		const headWidth = len * this.headWidthFactor;
		const tailLeft = getThirdPoint(pnt2, pnt1, HALF_PI, tailWidth, true);
		const tailRight = getThirdPoint(pnt2, pnt1, HALF_PI, tailWidth, false);
		const headLeft = getThirdPoint(
			pnt1,
			pnt2,
			this.headAngle,
			headWidth,
			false,
		);
		const headRight = getThirdPoint(
			pnt1,
			pnt2,
			this.headAngle,
			headWidth,
			true,
		);
		const neckLeft = getThirdPoint(
			pnt1,
			pnt2,
			this.neckAngle,
			neckWidth,
			false,
		);
		const neckRight = getThirdPoint(
			pnt1,
			pnt2,
			this.neckAngle,
			neckWidth,
			true,
		);
		const coords = [
			tailLeft,
			neckLeft,
			headLeft,
			pnt2,
			headRight,
			neckRight,
			tailRight,
		];

		return coords;
	}
}
